package model.registro;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import model.registro.Registro;

public class RegistroSimbolos extends Registro {

	// en BitArray guardamos los 16 bits
	private long probabilidad;

	
	public RegistroSimbolos() {
		this.probabilidad = 1;
	}

	public int getTamanioRegistro() {
		return Long.SIZE / 8;
	}

	public byte[] convertirRegistroABytes() throws IOException {

		ByteArrayOutputStream bytesRegistro = new ByteArrayOutputStream();
		DataOutputStream output = new DataOutputStream(bytesRegistro);

		output.writeLong(getProbabilidad());

		return bytesRegistro.toByteArray();

	}

	public void convertirBytesARegistro(byte[] xInput) throws IOException {

		ByteArrayInputStream bytesRegistro = new ByteArrayInputStream(xInput);
		DataInputStream input = new DataInputStream(bytesRegistro);

		setProbabilidad(input.readLong());
	}
	public long getProbabilidad() {
		return probabilidad;
	}
	public void setProbabilidad(long probabilidad) {
		this.probabilidad = probabilidad;
	}

}
